Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exploit new support in firefly-signer and firefly-common for large & scientific JSON numbers #153

Merged
merged 9 commits into from
Sep 4, 2024

Conversation

matthew1001
Copy link
Contributor

@matthew1001 matthew1001 commented Aug 27, 2024

This PR does 2 things:

  1. Pulls in the latest version of:
  2. Adds unit tests that exercise the new function introduced by those PRs

@matthew1001 matthew1001 marked this pull request as ready for review September 3, 2024 15:27
@matthew1001 matthew1001 requested a review from a team as a code owner September 3, 2024 15:27
Signed-off-by: Matthew Whitehead <[email protected]>
Copy link
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@@ -95,7 +95,7 @@ func (c *ethConnector) prepareDeployData(ctx context.Context, req *ffcapi.Contra
ethParams := make([]interface{}, len(req.Params))
for i, p := range req.Params {
if p != nil {
err := json.Unmarshal([]byte(*p), &ethParams[i])
err := p.Unmarshal(ctx, &ethParams[i])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context: The type of p is *fftypes.JSONAny which has implemented an Unmarshal method

@@ -39,19 +40,91 @@ const samplePrepareDeployTX = `{
"gas": 1000000,
"nonce": "111",
"value": "12345678901234567890123456789",
"contract": "0xfeedbeef",
"contract": "0xdeadbeef",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah a slightly cheeky way to ensure the asserts in the tests don't match on the contract bytes when checking for integers that match 0xdeadbeef

Copy link
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait don't we have to fix the invoke contract as well?

@EnriqueL8
Copy link
Contributor

You need the same fix in

err := json.Unmarshal([]byte(*p), &ethParams[i])

@EnriqueL8
Copy link
Contributor

Could it also affect the gas price

err := json.Unmarshal(input.Bytes(), &tx.GasPrice)
?

Signed-off-by: Matthew Whitehead <[email protected]>
@matthew1001
Copy link
Contributor Author

You need the same fix in

err := json.Unmarshal([]byte(*p), &ethParams[i])

Good spot, will address that now

@matthew1001
Copy link
Contributor Author

Could it also affect the gas price

err := json.Unmarshal(input.Bytes(), &tx.GasPrice)

?

I think this case is OK as we're specifically unmarshaling to a HexInteger not an interface{}

Signed-off-by: Matthew Whitehead <[email protected]>
@matthew1001
Copy link
Contributor Author

@EnriqueL8 new commits added to handle the prepare path, with unit tests

Copy link
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@EnriqueL8
Copy link
Contributor

Not sure why codecov is not enabled here...

@EnriqueL8
Copy link
Contributor

Okay I've enabled CodeCov on this repo

@EnriqueL8
Copy link
Contributor

Re-Running Jobs to upload coverage

@matthew1001 matthew1001 merged commit 102fac7 into hyperledger:main Sep 4, 2024
3 checks passed
@Chengxuan Chengxuan deleted the large-json-numbers branch September 4, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants